import { getUser, logout } from '@/request/axios'

async function queryInfo() {
  const localInfo = JSON.parse(localStorage.getItem('account'))
  // console.log(localInfo.type,"到这了");
  const type = localInfo.type
  const res = await getUser(type)
  const queryRes = res.data.result.find((item) => {
    return item.username == localInfo.username
  })
  // console.log(queryRes,'我把信息赛选出来了');
  return queryRes
}
async function logoutByOneself() {
  const localInfo = JSON.parse(localStorage.getItem('account'))
  const type = localInfo.type
  const username = localInfo.username
  const res = await logout(type, username)
  console.log(res, '退出登录')
  const token = null
  const account = null
  localStorage.setItem('token', token)
  localStorage.setItem('account', account)
  // 跳转回登录界面
  
}

export { queryInfo, logoutByOneself }
